package com.ruoyi.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.List;

/**
 * 用户信息对象 sys_user
 *
 * @author yfkj
 * @date 2021-10-12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUser extends com.ruoyi.common.core.web.domain.BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户信息主键 */
    @TableField(exist = true)
    @ApiModelProperty(value =  "${comment}")
    @TableId(type= IdType.AUTO)
    private Long userId;

    /** 部门ID */
    @com.ruoyi.common.core.annotation.Excel(name = "部门ID")
    @TableField(exist = true)
    @ApiModelProperty(value =  "部门ID")
    private Long deptId;

    /** 用户账号 */
    @com.ruoyi.common.core.annotation.Excel(name = "用户账号")
    @TableField(exist = true)
    @ApiModelProperty(value =  "用户账号")
    private String userName;

    /** 用户昵称 */
    @com.ruoyi.common.core.annotation.Excel(name = "用户昵称")
    @TableField(exist = true)
    @ApiModelProperty(value =  "用户昵称")
    private String nickName;

    /** 用户类型(00系统用户) */
    @com.ruoyi.common.core.annotation.Excel(name = "用户类型(00系统用户)")
    @TableField(exist = true)
    @ApiModelProperty(value =  "用户类型(00系统用户)")
    private String userType;

    /** 用户邮箱 */
    @com.ruoyi.common.core.annotation.Excel(name = "用户邮箱")
    @TableField(exist = true)
    @ApiModelProperty(value =  "用户邮箱")
    private String email;

    /** 手机号码 */
    @com.ruoyi.common.core.annotation.Excel(name = "手机号码")
    @TableField(exist = true)
    @ApiModelProperty(value =  "手机号码")
    private String phonenumber;

    /** 用户性别(0男 1女 2未知) */
    @com.ruoyi.common.core.annotation.Excel(name = "用户性别(0男 1女 2未知)")
    @TableField(exist = true)
    @ApiModelProperty(value =  "用户性别(0男 1女 2未知)")
    private String sex;

    /** 头像地址 */
    @com.ruoyi.common.core.annotation.Excel(name = "头像地址")
    @TableField(exist = true)
    @ApiModelProperty(value =  "头像地址")
    private String avatar;

    /** 密码 */
    @com.ruoyi.common.core.annotation.Excel(name = "密码")
    @TableField(exist = true)
    @ApiModelProperty(value =  "密码")
    private String password;

    /** 帐号状态(0正常 1停用) */
    @com.ruoyi.common.core.annotation.Excel(name = "帐号状态(0正常 1停用)")
    @TableField(exist = true)
    @ApiModelProperty(value =  "帐号状态(0正常 1停用)")
    private String status;

    /** 删除标志(0代表存在 2代表删除) */
    @TableField(exist = true)
    @ApiModelProperty(value =  "帐号状态(0正常 1停用)")
    private String delFlag;

    /** 最后登录IP */
    @com.ruoyi.common.core.annotation.Excel(name = "最后登录IP")
    @TableField(exist = true)
    @ApiModelProperty(value =  "最后登录IP")
    private String loginIp;

    /** 最后登录时间 */
    @com.ruoyi.common.core.annotation.Excel(name = "最后登录时间")
    @TableField(exist = true)
    @ApiModelProperty(value =  "最后登录时间")
    private Long loginDate;

    @TableField(exist = true)
    @ApiModelProperty(value =  "微信openID")
    private String wxOpenId;

    @TableField(exist = true)
    @ApiModelProperty(value =  "微信unionID")
    private String wxUnionId;

    @TableField(exist = true)
    @ApiModelProperty(value =  "微信昵称")
    private String wxNickName;

    @TableField(exist = true)
    @ApiModelProperty(value =  "微信头像")
    private String wxAvatarUrl;

    @TableField(exist = true)
    @ApiModelProperty(value =  "集成企业微信时传的企业id")
    private String corpId;

    @TableField(exist = true)
    @ApiModelProperty(value =  "集成钉钉时传的AppKey")
    private String appKey;

    @ApiModelProperty(value =  "人脸标识")
    private String faceToken;

    @ApiModelProperty(value =  "小程序字体大小（默认18px）")
    private Integer mpFontSize;

    @TableField(exist = false)
    @ApiModelProperty(value =  "角色列表")
    private List<SysRole> roles;

    @TableField(exist = false)
    @ApiModelProperty(value =  "角色主键列表")
    private Long[] roleIds;

    public static final String USER_ID="user_id";
    public static final String DEPT_ID="dept_id";
    public static final String USER_NAME="user_name";
    public static final String NICK_NAME="nick_name";
    public static final String USER_TYPE="user_type";
    public static final String EMAIL="email";
    public static final String PHONENUMBER="phonenumber";
    public static final String SEX="sex";
    public static final String AVATAR="avatar";
    public static final String PASSWORD="password";
    public static final String STATUS="status";
    public static final String DEL_FLAG="del_flag";
    public static final String LOGIN_IP="login_ip";
    public static final String LOGIN_DATE="login_date";
    public static final String CREATE_BY="create_by";
    public static final String CREATE_TIME="create_time";
    public static final String UPDATE_BY="update_by";
    public static final String UPDATE_TIME="update_time";
    public static final String REMARK="remark";
    public static final String CORP_ID="corp_id";
    public static final String APP_KEY="app_key";
    public static final String WX_OPEN_ID="wx_open_id";
    public static final String WX_UNION_ID="wx_union_id";
    public static final String WX_NICK_NAME="wx_nick_name";
    public static final String WX_AVATAR_URL="wx_avatar_url";
    public static final String FACE_TOKEN="face_token";
    public static final String MP_FONT_SIZE="mp_font_size";


    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("userId", getUserId())
                .append("deptId", getDeptId())
                .append("userName", getUserName())
                .append("nickName", getNickName())
                .append("userType", getUserType())
                .append("email", getEmail())
                .append("phonenumber", getPhonenumber())
                .append("sex", getSex())
                .append("avatar", getAvatar())
                .append("password", getPassword())
                .append("status", getStatus())
                .append("delFlag", getDelFlag())
                .append("loginIp", getLoginIp())
                .append("loginDate", getLoginDate())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }


}
